A very small and simple PC/MAC/DS rendering lib using the 3d core to render 2D stuff. More...
#include <stdio.h>#include <math.h>#include <string.h>#include <libraries/include/GL/glfw.h>Go to the source code of this file.
Classes | |
| struct | glImage |
| Struct for our GL-Based Images This is our struct to hold our image attributes. You don't need to worry about this if you use the texture packer. More... | |
Defines | |
| #define | ARGB_A(u) (((u) >> 24) & 0x000000FF) |
| #define | ARGB_R(u) (((u) >> 16) & 0x000000FF) |
| #define | ARGB_G(u) (((u) >> 8) & 0x000000FF) |
| #define | ARGB_B(u) (((u) >> 0) & 0x000000FF) |
| #define | RGBA(r, g, b, a) ((a) << 24 | (r) << 16 | (g) << 8 | (b) ) |
| #define | GL2D_RGBA(r, g, b, a) RGBA( b, g, r, a) |
| Macro to use for all the color arguments of Easy GL2D primitives. | |
| #define | true 1 |
| #define | false 0 |
Typedefs | |
| typedef enum GL2D_FLIP_MODE | GL2D_FLIP_MODE |
| Enums selecting flipping mode. | |
| typedef enum GL2D_BLEND_MODE | GL2D_BLEND_MODE |
| Enums selecting Blending/Blitting mode. | |
| typedef struct glImage | glImage |
| Struct for our GL-Based Images This is our struct to hold our image attributes. You don't need to worry about this if you use the texture packer. | |
Enumerations | |
| enum | GL2D_FLIP_MODE { GL2D_FLIP_NONE = 1 << 0, GL2D_FLIP_V = 1 << 1, GL2D_FLIP_H = 1 << 2 } |
Enums selecting flipping mode. More... | |
| enum | GL2D_BLEND_MODE { GL2D_TRANS = 0, GL2D_SOLID, GL2D_BLENDED, GL2D_GLOW, GL2D_ALPHA, GL2D_BLACK } |
Enums selecting Blending/Blitting mode. More... | |
Functions | |
| void | glBegin2D (const int width, const int height) |
| Sets up OpenGL for 2d rendering. Call this before drawing any of GL2D's drawing or sprite functions. | |
| void | glEnd2D () |
| Issue this after drawing 2d so that we don't mess the matrix stack. The compliment of glBegin2D(). | |
| void | glScreen2D (const int width, const int height, const int mode) |
| Initializes GL in 2D mode. | |
| void | glScreen2DEx (const int width, const int height, const int mode, const int depthbits, const int stencilbits) |
| Initializes GL in 2D mode with more control. | |
| void | glClose () |
| Cleans up Easy GL2D. Call this at program end. External texture management is up for the user to clean up. | |
| void | glBlendMode (const GL2D_BLEND_MODE mode) |
| Sets the default blending/blitting mode. | |
| void | glEnableSpriteStencil (const GLuint gl2dcolor, const GLuint gl2dcolor_env, int flag) |
| Sets texture environment color Used to draw sprites in a single fill color Very useful for flash/hit animations (1 - (texture image color)) * (glColor color) + (texture image color) * (texture environment color) ie. Pure White Sprites. | |
| void | glEnableAntialias (int flag) |
| void | glClearScreen () |
| Clears the GL2D screen buffer. | |
| void | glLineGlow (const int x1, const int y1, const int x2, const int y2, const int width, const GLuint color) |
| Draws a glowing line. | |
| void | glPutPixel (int x, int y, const GLuint color) |
| Draws a Pixel. | |
| void | glLine (int x1, int y1, int x2, int y2, const GLuint color) |
| Draws a Line. | |
| void | glLineGradient (int x1, int y1, int x2, int y2, const GLuint color1, const GLuint color2) |
| Draws a Line in a gradient color. | |
| void | glBox (int x1, int y1, int x2, int y2, const GLuint color) |
| Draws a Box. | |
| void | glBoxFilled (int x1, int y1, int x2, int y2, const GLuint color) |
| Draws a Box filled with a single color. | |
| void | glBoxFilledGradient (int x1, int y1, int x2, int y2, const GLuint color1, const GLuint color2, const GLuint color3, const GLuint color4) |
| Draws a Box filled with a gradient color. | |
| void | glTriangle (int x1, int y1, int x2, int y2, int x3, int y3, const GLuint color) |
| Draws a Triangle. | |
| void | glTriangleFilled (int x1, int y1, int x2, int y2, int x3, int y3, const GLuint color) |
| Draws a Triangle filled with a single color. | |
| void | glTriangleFilledGradient (int x1, int y1, int x2, int y2, int x3, int y3, const GLuint color1, const GLuint color2, const GLuint color3) |
| Draws a Triangle filled with a gradient color. | |
| void | glEllipse (int x, int y, int a, int b, int degrees, const GLuint color) |
| Draws a hollow Ellipse. | |
| void | glEllipseFilled (int x, int y, int a, int b, int degrees, const GLuint color) |
| Draws a filled Ellipse. | |
| void | glSprite (const int x, const int y, const int flipmode, const glImage *spr) |
| Draws a Sprite. | |
| void | glSpriteScale (const int x, const int y, const float scale, const int flipmode, const glImage *spr) |
| Draws a Scaled Sprite. | |
| void | glSpriteScaleXY (const int x, const int y, const float scaleX, const float scaleY, const int flipmode, const glImage *spr) |
| Draws an Axis Exclusive Scaled Sprite. | |
| void | glSpriteRotate (const int x, const int y, const int angle, const int flipmode, const glImage *spr) |
| Draws a Center Rotated Sprite. | |
| void | glSpriteRotateScale (const int x, const int y, const int angle, const float scale, const int flipmode, const glImage *spr) |
| Draws a Center Rotated Scaled Sprite. | |
| void | glSpriteRotateScaleXY (const int x, const int y, const int angle, const float scaleX, const float scaleY, const int flipmode, const glImage *spr) |
| Draws a Center Rotated Axis-Exclusive Scaled Sprite. | |
| void | glSpriteOnQuad (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, float uoff, float voff, int flipmode, const glImage *spr) |
| Draws a Stretched Sprite across a quad Useful for "Shrearing Effects". | |
| void | glSpriteOnQuadClipped (int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, float luclip, float lvclip, float ruclip, float rvclip, int flipmode, const glImage *spr) |
| Draws a Stretched Sprite across a quad with clipped textures<Br> I needed this for my ikaruga laser implementation. | |
| void | glSpriteStretchHorizontal (int x, int y, int length, const glImage *spr) |
| Draws a clean horizontally stretched Sprite<Br> Useful for lasers and huds. | |
| void | glSpriteStretchVertical (int x, int y, int height, const glImage *spr) |
| Draws a clean vertically stretched Sprite<Br> Useful for lasers and huds. | |
| void | glSpriteStretchHV (int x, int y, int length, int height, const glImage *spr) |
| Draws a clean horizontally and vertically stretched Sprite<Br> Useful for lasers, huds and dialog boxes. | |
| void | glPrint (int x, int y, const char *text, const GLuint color) |
| Prints a rudimentary text for feedback/debugging purposes<Br> Not to be used in actual application/games as it is extremely sloooow. Rasterfont from the GLRedbook. | |
| GLuint | glLoadSpriteSet (const char *filename, glImage *sprite, const int width, const int height, const int numframes, const unsigned int *texcoords, const GLuint filtermode) |
| Initializes our spriteset with Texture Packer generated UV coordinates Very safe and easy to use.. | |
| GLuint | glLoadTileSet (const char *filename, glImage *sprite, const int tile_wid, const int tile_hei, const int bmp_wid, const int bmp_hei, const GLuint filtermode) |
| Initializes our Tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files. Can only be used when tiles in a tilset are of the same dimensions. | |
| GLuint | glLoadSprite (const char *filename, glImage *sprite, const int width, const int height, const GLuint filtermode) |
| Loads a single power of 2 image. | |
| void | glGet (glImage *SpriteDest, const glImage *SpriteSource, int x1, int y1, int x2, int y2) |
| "Gets" a tile from a loaded spriteset. | |
A very small and simple PC/MAC/DS rendering lib using the 3d core to render 2D stuff.
Definition in file gl2d.h.
| #define GL2D_RGBA | ( | r, | |
| g, | |||
| b, | |||
| a | |||
| ) | RGBA( b, g, r, a) |
| typedef enum GL2D_BLEND_MODE GL2D_BLEND_MODE |
Enums selecting Blending/Blitting mode.
| typedef enum GL2D_FLIP_MODE GL2D_FLIP_MODE |
Enums selecting flipping mode.
These enums are bits for flipping the sprites.
You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip both ways.
Struct for our GL-Based Images
This is our struct to hold our image attributes. You don't need to worry about this if you use the texture packer.
Struct for out GL-Based Images.
This is our struct to hold our image attributes.
You don't need to worry about this if you use the texture packer.
| enum GL2D_BLEND_MODE |
| enum GL2D_FLIP_MODE |
Enums selecting flipping mode.
These enums are bits for flipping the sprites.
You can "|" (or) GL_FLIP_V and GL_FLIP_H to flip both ways.
| void glBegin2D | ( | const int | width, |
| const int | height | ||
| ) |
| void glBlendMode | ( | const GL2D_BLEND_MODE | mode ) |
| void glBox | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| const GLuint | color | ||
| ) |
| void glBoxFilled | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| const GLuint | color | ||
| ) |
| void glBoxFilledGradient | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| const GLuint | color1, | ||
| const GLuint | color2, | ||
| const GLuint | color3, | ||
| const GLuint | color4 | ||
| ) |
Draws a Box filled with a gradient color.
| x1,y1 | Top-Left coordinate of the box. |
| x2,y2 | Bottom-Right coordinate of the box. |
| color1 | GL2D_RGBA color of the Top-Left corner. |
| color2 | GL2D_RGBA color of the Bottom-Left corner. |
| color3 | GL2D_RGBA color of the Bottom-Right corner. |
| color4 | GL2D_RGBA color of the Top-Right corner. |
| void glEllipse | ( | int | x, |
| int | y, | ||
| int | a, | ||
| int | b, | ||
| int | degrees, | ||
| const GLuint | color | ||
| ) |
| void glEllipseFilled | ( | int | x, |
| int | y, | ||
| int | a, | ||
| int | b, | ||
| int | degrees, | ||
| const GLuint | color | ||
| ) |
| void glEnableAntialias | ( | int | flag ) |
| void glEnableSpriteStencil | ( | const GLuint | gl2dcolor, |
| const GLuint | gl2dcolor_env, | ||
| int | flag | ||
| ) |
Sets texture environment color Used to draw sprites in a single fill color Very useful for flash/hit animations (1 - (texture image color)) * (glColor color) + (texture image color) * (texture environment color) ie. Pure White Sprites.
| gl2dcolor | color. |
| gl2dcolor_env | environment color. |
| flag | true == blendmode; false(0) == modulate. |
| void glLine | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| const GLuint | color | ||
| ) |
| void glLineGlow | ( | const int | x1, |
| const int | y1, | ||
| const int | x2, | ||
| const int | y2, | ||
| const int | width, | ||
| const GLuint | color | ||
| ) |
| void glLineGradient | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| const GLuint | color1, | ||
| const GLuint | color2 | ||
| ) |
| GLuint glLoadSprite | ( | const char * | filename, |
| glImage * | sprite, | ||
| const int | width, | ||
| const int | height, | ||
| const GLuint | filtermode | ||
| ) |
| GLuint glLoadSpriteSet | ( | const char * | filename, |
| glImage * | sprite, | ||
| const int | width, | ||
| const int | height, | ||
| const int | numframes, | ||
| const unsigned int * | texcoords, | ||
| const GLuint | filtermode | ||
| ) |
Initializes our spriteset with Texture Packer generated UV coordinates
Very safe and easy to use..
| filename | filename of the TGA file to load ie. "ships.tga". |
| sprite | Pointer to an array of glImage. |
| width | The horizontal size of the texture |
| height | The vertical size of the texture |
| numframes | number of frames in a spriteset (auto-generated by Texture Packer). |
| texcoords | Texture Packer auto-generated array of UV coords. |
| filtermode | GL_NEAREST or GL_LINEAR. |
| GLuint glLoadTileSet | ( | const char * | filename, |
| glImage * | sprite, | ||
| const int | tile_wid, | ||
| const int | tile_hei, | ||
| const int | bmp_wid, | ||
| const int | bmp_hei, | ||
| const GLuint | filtermode | ||
| ) |
Initializes our Tileset (like glInitSpriteset()) but without the use of Texture Packer auto-generated files.
Can only be used when tiles in a tilset are of the same dimensions.
| filename | filename of the TGA file to load ie. "ships.tga". |
| sprite | Pointer to an array of glImage. |
| tile_wid | Width of each tile in the texture. |
| tile_hei | Height of each tile in the texture. |
| bmp_wid | Width of of the texture or tileset. |
| bmp_hei | height of of the texture or tileset. |
| filtermode | GL_NEAREST or GL_LINEAR. |
| void glPrint | ( | int | x, |
| int | y, | ||
| const char * | text, | ||
| const GLuint | color | ||
| ) |
Prints a rudimentary text for feedback/debugging purposes<Br> Not to be used in actual application/games as it is extremely sloooow. Rasterfont from the GLRedbook.
| x,y | Location of the sprite. |
| text | text to print. |
| color | GL2D_RGBA color of the Top-Right corner. |
| void glPutPixel | ( | int | x, |
| int | y, | ||
| const GLuint | color | ||
| ) |
| void glScreen2D | ( | const int | width, |
| const int | height, | ||
| const int | mode | ||
| ) |
| void glScreen2DEx | ( | const int | width, |
| const int | height, | ||
| const int | mode, | ||
| const int | depthbits, | ||
| const int | stencilbits | ||
| ) |
| void glSprite | ( | const int | x, |
| const int | y, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
| void glSpriteOnQuad | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | x3, | ||
| int | y3, | ||
| int | x4, | ||
| int | y4, | ||
| float | uoff, | ||
| float | voff, | ||
| int | flipmode, | ||
| const glImage * | spr | ||
| ) |
Draws a Stretched Sprite across a quad
Useful for "Shrearing Effects".
| x1,y1 | First corner of the sprite. |
| x2,y2 | Second corner of the sprite. |
| x3,y3 | Third corner of the sprite. |
| x4,y4 | Fourth corner of the sprite. |
| uoff,voff | texture offsets. |
| flipmode | mode for flipping (see GL2D_FLIP_MODE enum). |
| spr | pointer to a glImage. |
| void glSpriteOnQuadClipped | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | x3, | ||
| int | y3, | ||
| int | x4, | ||
| int | y4, | ||
| float | luclip, | ||
| float | lvclip, | ||
| float | ruclip, | ||
| float | rvclip, | ||
| int | flipmode, | ||
| const glImage * | spr | ||
| ) |
Draws a Stretched Sprite across a quad with clipped textures<Br> I needed this for my ikaruga laser implementation.
| x1,y1 | First corner of the sprite. |
| x2,y2 | Second corner of the sprite. |
| x3,y3 | Third corner of the sprite. |
| x4,y4 | Fourth corner of the sprite. |
| luclip,lvclip | left horizo/vertical ntaltexture offsets. |
| ruclip,rvclip | right horizo/vertical ntaltexture offsets. |
| flipmode | mode for flipping (see GL2D_FLIP_MODE enum). |
| spr | pointer to a glImage. |
| void glSpriteRotate | ( | const int | x, |
| const int | y, | ||
| const int | angle, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
| void glSpriteRotateScale | ( | const int | x, |
| const int | y, | ||
| const int | angle, | ||
| const float | scale, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
Draws a Center Rotated Scaled Sprite.
| x | X position of the sprite center. |
| y | Y position of the sprite center. |
| angle | Angle(in degrees) to rotate the sprite. |
| scale | scale value (1.0f is normal). |
| flipmode | mode for flipping (see GL2D_FLIP_MODE enum). |
| spr | pointer to a glImage. |
| void glSpriteRotateScaleXY | ( | const int | x, |
| const int | y, | ||
| const int | angle, | ||
| const float | scaleX, | ||
| const float | scaleY, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
Draws a Center Rotated Axis-Exclusive Scaled Sprite.
| x | X position of the sprite center. |
| y | Y position of the sprite center. |
| angle | Angle(in degrees) to rotate the sprite. |
| scaleX | X-Axis scale value (1.0f is normal). |
| scaleY | Y-Axis scale value (1.0f is normal). |
| flipmode | mode for flipping (see GL2D_FLIP_MODE enum). |
| spr | pointer to a glImage. |
| void glSpriteScale | ( | const int | x, |
| const int | y, | ||
| const float | scale, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
| void glSpriteScaleXY | ( | const int | x, |
| const int | y, | ||
| const float | scaleX, | ||
| const float | scaleY, | ||
| const int | flipmode, | ||
| const glImage * | spr | ||
| ) |
Draws an Axis Exclusive Scaled Sprite.
| x | X position of the sprite. |
| y | Y position of the sprite. |
| scaleX | X-Axis scale value (1.0f is normal). |
| scaleY | Y-Axis scale value (1.0f is normal). |
| flipmode | mode for flipping (see GL2D_FLIP_MODE enum). |
| spr | pointer to a glImage. |
| void glSpriteStretchHorizontal | ( | int | x, |
| int | y, | ||
| int | length, | ||
| const glImage * | spr | ||
| ) |
| void glSpriteStretchHV | ( | int | x, |
| int | y, | ||
| int | length, | ||
| int | height, | ||
| const glImage * | spr | ||
| ) |
| void glSpriteStretchVertical | ( | int | x, |
| int | y, | ||
| int | height, | ||
| const glImage * | spr | ||
| ) |
| void glTriangle | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | x3, | ||
| int | y3, | ||
| const GLuint | color | ||
| ) |
| void glTriangleFilled | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | x3, | ||
| int | y3, | ||
| const GLuint | color | ||
| ) |
| void glTriangleFilledGradient | ( | int | x1, |
| int | y1, | ||
| int | x2, | ||
| int | y2, | ||
| int | x3, | ||
| int | y3, | ||
| const GLuint | color1, | ||
| const GLuint | color2, | ||
| const GLuint | color3 | ||
| ) |
Draws a Triangle filled with a gradient color.
| x1,y1 | Vertex 1 of the triangle. |
| x2,y2 | Vertex 2 of the triangle. |
| x3,y3 | Vertex 3 of the triangle. |
| color1 | GL2D_RGBA color of the vertex 1. |
| color2 | GL2D_RGBA color of the vertex 2. |
| color3 | GL2D_RGBA color of the vertex 3. |
1.7.2